home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / StatusBarBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  9KB  |  248 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  08/19/98    LAB    Moved to GroupAWTAdditions folder.
  8.  
  9. /**
  10.  * BeanInfo for StatusBar.
  11.  *
  12.  */
  13.  
  14. public class StatusBarBeanInfo extends SimpleBeanInfo {
  15.  
  16.     /**
  17.      * Constructs a StatusBarBeanInfo object.
  18.      */
  19.     public StatusBarBeanInfo() {
  20.     }
  21.  
  22.     /**
  23.      * Gets a BeanInfo for the superclass of this bean.
  24.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  25.      */
  26.     public BeanInfo[] getAdditionalBeanInfo() {
  27.         try {
  28.             BeanInfo[] bi = new BeanInfo[1];
  29.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  30.             return bi;
  31.         }
  32.         catch (IntrospectionException e) { throw new Error(e.toString());}
  33.     }
  34.  
  35.     /**
  36.      * Gets the SymantecBeanDescriptor for this bean.
  37.      * @return an object of type SymantecBeanDescriptor
  38.      * @see symantec.itools.beans.SymantecBeanDescriptor
  39.      */
  40.     public BeanDescriptor getBeanDescriptor() {
  41.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  42.         String s=group.getString("GroupAWTAdditions"); 
  43.  
  44.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  45.         bd.setCanAddChild(false);
  46.         bd.setWinHelp("0x12390");
  47.         bd.setFolder(s);
  48.         bd.setToolbar(s);
  49.  
  50.         bd.addAdditionalConnections(getAdditionalBeanInfo());
  51.  
  52.         return (BeanDescriptor) bd;
  53.     }
  54.  
  55.     /**
  56.      * Gets an image that may be used to visually represent this bean
  57.      * (in the toolbar, on a form, etc).
  58.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  59.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  60.      * @return an image for this bean, always color even if requested monochrome
  61.      * @see BeanInfo#ICON_MONO_16x16
  62.      * @see BeanInfo#ICON_COLOR_16x16
  63.      * @see BeanInfo#ICON_MONO_32x32
  64.      * @see BeanInfo#ICON_COLOR_32x32
  65.      */
  66.     public java.awt.Image getIcon(int iconKind) {
  67.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  68.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  69.             java.awt.Image img = loadImage("StatusBarC16.gif");
  70.             return img;
  71.         }
  72.  
  73.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  74.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  75.             java.awt.Image img = loadImage("StatusBarC32.gif");
  76.             return img;
  77.         }
  78.  
  79.         return null;
  80.     }
  81.  
  82.     /**
  83.      * Gets an array of descriptions of the methods used for "connections" by
  84.      * Visual CafΘ's Interaction Wizard.
  85.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  86.      * @return method descriptions for this bean
  87.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  88.      */
  89.     public MethodDescriptor[] getMethodDescriptors() {
  90.         Class[] args;
  91.         ConnectionDescriptor connection;
  92.         java.util.Vector connections;
  93.         java.util.Vector md = new java.util.Vector();
  94.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  95.  
  96.         try{
  97.             args = null;
  98.             MethodDescriptor getStatusTextColor = new MethodDescriptor(beanClass.getMethod("getStatusTextColor", args));
  99.  
  100.             connections = new java.util.Vector();
  101.             connection = new ConnectionDescriptor("output", "Color", "",
  102.                                     "%name%.getStatusTextColor();",
  103.                                     conn.getString("getStatusTextColor"));
  104.             connections.addElement(connection);
  105.  
  106.             getStatusTextColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  107.             md.addElement(getStatusTextColor);
  108.         } catch (Exception e) { throw new Error("getStatusTextColor:: " + e.toString()); }
  109.  
  110.         try{
  111.             args = new Class[1];
  112.             args[0] = java.lang.String.class ;
  113.             MethodDescriptor setStatusText = new MethodDescriptor(beanClass.getMethod("setStatusText", args));
  114.  
  115.             connections = new java.util.Vector();
  116.             connection = new ConnectionDescriptor("input", "String", "",
  117.                                     "%name%.setStatusText(%arg%);",
  118.                                     conn.getString("setStatusText"));
  119.             connections.addElement(connection);
  120.  
  121.             setStatusText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  122.             md.addElement(setStatusText);
  123.         } catch (Exception e) { throw new Error("setStatusText:: " + e.toString()); }
  124.  
  125.         try{
  126.             args = null;
  127.             MethodDescriptor getStatusText = new MethodDescriptor(beanClass.getMethod("getStatusText", args));
  128.  
  129.             connections = new java.util.Vector();
  130.             connection = new ConnectionDescriptor("output", "String", "",
  131.                                     "%name%.getStatusText()",
  132.                                     conn.getString("getStatusText"));
  133.             connections.addElement(connection);
  134.  
  135.             getStatusText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  136.             md.addElement(getStatusText);
  137.         } catch (Exception e) { throw new Error("getStatusText:: " + e.toString()); }
  138.  
  139.         try{
  140.             args = new Class[1];
  141.             args[0] = java.awt.Color.class ;
  142.             MethodDescriptor setStatusTextColor = new MethodDescriptor(beanClass.getMethod("setStatusTextColor", args));
  143.  
  144.             connections = new java.util.Vector();
  145.             connection = new ConnectionDescriptor("input", "Color", "",
  146.                                     "%name%.setStatusTextColor(%arg%);",
  147.                                     conn.getString("setStatusTextColor"));
  148.             connections.addElement(connection);
  149.  
  150.             setStatusTextColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  151.             md.addElement(setStatusTextColor);
  152.         } catch (Exception e) { throw new Error("setStatusTextColor:: " + e.toString()); }
  153.  
  154.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  155.         md.copyInto(rv);
  156.  
  157.         return rv;
  158.     }
  159.  
  160.     /**
  161.      * Returns descriptions of this bean's properties.
  162.      */
  163.     public PropertyDescriptor[] getPropertyDescriptors() {
  164.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  165.  
  166.         try{
  167.         PropertyDescriptor defProperty = new PropertyDescriptor("statusText", beanClass);
  168.         defProperty.setBound(true);
  169.         defProperty.setConstrained(true);
  170.         defProperty.setDisplayName(prop.getString("statusText"));
  171.  
  172.         PropertyDescriptor statusTextColor = new PropertyDescriptor("statusTextColor", beanClass);
  173.         statusTextColor.setBound(true);
  174.         statusTextColor.setConstrained(true);
  175.         statusTextColor.setDisplayName(prop.getString("statusTextColor"));
  176.  
  177.         PropertyDescriptor paddingTop = new PropertyDescriptor("paddingTop", beanClass);
  178.         paddingTop.setBound(true);
  179.         paddingTop.setConstrained(true);
  180.         paddingTop.setDisplayName(prop.getString("paddingTop"));
  181.  
  182.         PropertyDescriptor paddingBottom = new PropertyDescriptor("paddingBottom", beanClass);
  183.         paddingBottom.setBound(true);
  184.         paddingBottom.setConstrained(true);
  185.         paddingBottom.setDisplayName(prop.getString("paddingBottom"));
  186.  
  187.         PropertyDescriptor paddingLeft = new PropertyDescriptor("paddingLeft", beanClass);
  188.         paddingLeft.setBound(true);
  189.         paddingLeft.setConstrained(true);
  190.         paddingLeft.setDisplayName(prop.getString("paddingLeft"));
  191.  
  192.         PropertyDescriptor paddingRight = new PropertyDescriptor("paddingRight", beanClass);
  193.         paddingRight.setBound(true);
  194.         paddingRight.setConstrained(true);
  195.         paddingRight.setDisplayName(prop.getString("paddingRight"));
  196.  
  197.         PropertyDescriptor iPadTop = new PropertyDescriptor("iPadTop", beanClass);
  198.         iPadTop.setBound(true);
  199.         iPadTop.setConstrained(true);
  200.         iPadTop.setDisplayName(prop.getString("iPadTop"));
  201.  
  202.         PropertyDescriptor iPadBottom = new PropertyDescriptor("iPadBottom", beanClass);
  203.         iPadBottom.setBound(true);
  204.         iPadBottom.setConstrained(true);
  205.         iPadBottom.setDisplayName(prop.getString("iPadBottom"));
  206.  
  207.         PropertyDescriptor iPadSides = new PropertyDescriptor("iPadSides", beanClass);
  208.         iPadSides.setBound(true);
  209.         iPadSides.setConstrained(true);
  210.         iPadSides.setDisplayName(prop.getString("iPadSides"));
  211.  
  212.         PropertyDescriptor borderColor = new PropertyDescriptor("borderColor", beanClass);
  213.         borderColor.setBound(true);
  214.         borderColor.setConstrained(true);
  215.         borderColor.setDisplayName(prop.getString("borderColor"));
  216.  
  217.         PropertyDescriptor bevelStyle = new PropertyDescriptor("bevelStyle", beanClass);
  218.         bevelStyle.setBound(true);
  219.         bevelStyle.setConstrained(true);
  220.         bevelStyle.setDisplayName(prop.getString("bevelStyle"));
  221.         bevelStyle.setValue("ENUMERATION", "BEVEL_LOWERED=0, BEVEL_RAISED=1, BEVEL_LINE=2, BEVEL_NONE=3");
  222.  
  223.         PropertyDescriptor[] rv = {
  224.             defProperty,
  225.             statusTextColor,
  226.             paddingTop,
  227.             paddingBottom,
  228.             paddingLeft,
  229.             paddingRight,
  230.             iPadTop,
  231.             iPadBottom,
  232.             iPadSides,
  233.             borderColor,
  234.             bevelStyle};
  235.         return rv;
  236.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  237.     }
  238.  
  239.     /**
  240.      * Returns the index of the property expected to be changed most often by the designer.
  241.      */
  242.     public int getDefaultPropertyIndex() {
  243.         return 0;    //  the index for our default property is always 0
  244.     }
  245.  
  246.     private final static Class beanClass = StatusBar.class;
  247.  
  248.     }    //  end of class StatusBarBeanInfo